<?php

class EmployeeController extends ExtCRUDController
{

    protected function handleReadAction()
    {
        $pi = $this->getPagingInfo();
        $total = Employee::model()->count();
        $data = Employee::model()->findAll(
                        '1=1 order by EmployeeId limit :limit offset :offset',
                        array(':limit' => $pi['limit'], ':offset' => $pi['start'])
        );

        return $this->ExportToJSONDataSource($data, $total);
    }

    protected function handleCreateAction($rows)
    {
        $emp = new Employee();
        $emp->attributes = $rows;
        return array('success'=>$emp->save(),'errors'=>$emp->getErrors());
    }

    protected function handleDestroyAction($id)
    {
        $record = Employee::model()->findByPk($id);
        $record->delete();
        return true;
    }

    protected function handleUpdateAction($rows)
    {
        $record = Employee::model()->findByPk($rows['EmployeeId']);
        $record->attributes = $rows;
        return array('success'=>$record->save(),'errors'=>$record->getErrors());
    }
}

?>